package com.project.pudongdata.controller;


import com.project.dto.R;
import com.project.pudongdata.dto.AuthenticationDto;
import com.project.pudongdata.service.AuthenticationService;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController
@RequestMapping("/authentication")
public class AuthenticationController {
    @Resource
    private AuthenticationService authenticationService;

    @RequestMapping("/sign")
    public R sign(@RequestBody AuthenticationDto authenticationDto)
    {
        if(!authenticationService.check(authenticationDto.getUsername(),authenticationDto.getPassword())){
            return R.fail("用户名密码不存在或错误");
        }
        String sign  = authenticationService.getSign(authenticationDto.getUsername(),authenticationDto.getPassword());
        return R.success(sign);
    }
}
